var myVideo = document.getElementById('my-video');

    // function autoPlayAudio2() {
    //     window.onload = function() {
    //         // alert(typeof WeixinJSBridge);
    //         WeixinJSBridge.invoke('getNetworkType', {}, function(e) {
    //             // 在这里拿到 e.err_msg, 这里面就包含了所有的网络类型
    //             // alert(e.err_msg);
    //             myVideo.play();
    //         });
    //     };
    // }
    // autoPlayAudio2();

    // function isWeiXin(){ 
    //     var ua = window.navigator.userAgent.toLowerCase(); 
    //     if(ua.match(/MicroMessenger/i) == 'micromessenger'){ 
    //         return true; 
    //     }else{ 
    //         return false; 
    //     } 
    // } 
    // 控制声音
    // var open = document.getElementsByClassName('control-open')[0],
    //     close = document.getElementsByClassName('control-close')[0],
    //     controlBox = document.getElementsByClassName('control-box')[0],
    //     flag = false;//声音关闭状态
    // controlBox.onclick = function(){
    //     flag = !flag;
    //     if(flag){
    //         myVideo.muted = true;
    //         close.style.display = 'none';
    //         open.style.display = 'block';
    //     }else{
    //         myVideo.muted = false;
    //         close.style.display = 'block';
    //         open.style.display = 'none';
    //     }
    // }
    // var isWeiXin = isWeiXin();

    // 判断手机型号
    // function ismobile(test){
    //     var u = navigator.userAgent, app = navigator.appVersion;
    //     if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
    //     if(window.location.href.indexOf("?mobile")<0){
    //     try{
    //     if(/iPhone|mac|iPod|iPad/i.test(navigator.userAgent)){
    //         return '0';
    //     }else{
    //         return '1';
    //     }
    //     }catch(e){}
    //     }
    //     }else if( u.indexOf('iPad') > -1){
    //         return '0';
    //     }else{
    //         return '1';
    //     }
    // };
    // var pla = ismobile(1)

    // if(!isWeiXin){
        // myVideo.setAttribute("controls","true")
    // }
    // 控制背景音乐
    var audio = document.getElementById('music'),
    openBtn = document.getElementsByClassName('control-open')[0],
    close = document.getElementsByClassName('control-close')[0],
    controlBox = document.getElementsByClassName('control-box')[0],
    flag = true;//声音开启状态
//音乐自动播放
$(document).ready(function(){
    autoPlayMusic();
    audioAutoPlay();
});
function audioAutoPlay() {
    audio.play();
    document.addEventListener("WeixinJSBridgeReady", function () {
        audio.play();
    }, false);
}
// 音乐播放
function autoPlayMusic() {
    // 自动播放音乐效果，解决浏览器或者APP自动播放问题
    function musicInBrowserHandler() {
        musicPlay(true);
        document.body.removeEventListener('touchstart', musicInBrowserHandler);
    }
    document.body.addEventListener('touchstart', musicInBrowserHandler);
    // 自动播放音乐效果，解决微信自动播放问题
    function musicInWeixinHandler() {
        musicPlay(true);
        document.addEventListener("WeixinJSBridgeReady", function () {
            musicPlay(true);
        }, false);
        document.removeEventListener('DOMContentLoaded', musicInWeixinHandler);
    }
    document.addEventListener('DOMContentLoaded', musicInWeixinHandler);
}
function musicPlay(isPlay) {
    if (isPlay && audio.paused) {
        audio.play();
    }
    if (!isPlay && !audio.paused) {
        audio.pause();
    }
}
controlBox.onclick = function(){
    flag = !flag;
    if(flag){
        music.play();
        close.style.display = 'block';
        openBtn.style.display = 'none';
    }else{
        music.pause();
        close.style.display = 'none';
        openBtn.style.display = 'block';
    }
    
}